getAjaxReq("home/nowRechargeApply", {}, function (res) {
    if (res.code == 1) {
        $("#nowRechargeApply").text(res.data)
    } else {
        $("#nowRechargeApply").text(0)
    }
})
getAjaxReq("home/recentWeekRechargeApply", {}, function (res) {
    if (res.code == 1) {
        $("#recentWeekRechargeApply").text(res.data)
    } else {
        $("#recentWeekRechargeApply").text(0)
    }
})
getAjaxReq("home/recentMonthRechargeApply", {}, function (res) {
    if (res.code == 1) {
        $("#recentMonthRechargeApply").text(res.data)
    } else {
        $("#recentMonthRechargeApply").text(0)
    }
})
getAjaxReq("home/totalRechargeApply", {}, function (res) {
    if (res.code == 1) {
        $("#totalRechargeApply").text(res.data)
    } else {
        $("#totalRechargeApply").text(0)
    }
})
getAjaxReq("home/warnAmmeters", {warnTime: 60 * 24}, function (res) {
    var option = {
        tooltip: {
            trigger: 'item',
            formatter: "{a} <br/>{b} : {c} ({d}%)"
        },
        legend: {
            orient: 'vertical',
            x: 'right',
            data: ['在线数', '离线数']
        }
    };
    var warnAmmeters = echarts.init(document.getElementById("warnAmmeters"));
    if (res.code == 1) {
        var total = res.data.total
        var warnTotal = res.data["warnTotal"]
        option.series = [
            {
                name: "电表在线率",
                type: 'pie',
                center: ['50%', '50%'],
                color: ['#cb2a08', '#13ad6b'],
                data: [
                    {
                        value: warnTotal,
                        name: '离线数',
                        label: {show: false},
                        labelLine: {show: false}
                    },
                    {
                        value: total - warnTotal, name: '在线数',
                        label: {
                            show: true,
                            position: 'center',
                            formatter: function (params) {
                                if (total != 0) {
                                    return (params.value / total * 100).toFixed(2) + '%'
                                } else
                                    return '0%'
                            },
                            color: '#fff',
                            fontSize: 18
                        }
                    }
                ]
            }
        ]
    } else {
        option.series = []
    }
    warnAmmeters.setOption(option)
})
